package com.example.lala.mvp.view;

import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

import com.example.lala.R;
import com.example.lala.mvp.view.fragment.Pig1Fragment;
import com.example.lala.mvp.view.fragment.Pig2Fragment;
import com.example.lala.mvp.view.fragment.Pig3Fragment;
import com.example.mylibrary.mvp.view.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {


    @BindView(R.id.fl)
    FrameLayout fl;
    @BindView(R.id.bt1)
    RadioButton bt1;
    @BindView(R.id.bt2)
    RadioButton bt2;
    @BindView(R.id.bt3)
    RadioButton bt3;
    private Pig1Fragment pig1Fragment=new Pig1Fragment();
    private Pig2Fragment pig2Fragment=new Pig2Fragment();
    private Pig3Fragment pig3Fragment=new Pig3Fragment();

    @Override
    public int bondLayout() {
        return R.layout.activity_main;
    }
    @Override
    public void initView() {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fl,pig1Fragment)
                .add(R.id.fl,pig2Fragment)
                .add(R.id.fl,pig3Fragment)
                .commit();
        show(pig2Fragment);
    }
    @OnClick({R.id.bt1, R.id.bt2, R.id.bt3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt1:
                show(pig1Fragment);
                Toast.makeText(this, "1111", Toast.LENGTH_SHORT).show();;
                break;
            case R.id.bt2:
                Toast.makeText(this, "已登陆", Toast.LENGTH_SHORT).show();;
                show(pig2Fragment);
                break;
            case R.id.bt3:
                show(pig3Fragment);
                break;
        }
    }

    public void show(Fragment fragment){
        getSupportFragmentManager().beginTransaction()
               .hide(pig1Fragment)
                .hide(pig2Fragment)
                .hide(pig3Fragment)
                .show(fragment)
                .commit();
    }



    @Override
    public void initData() {

    }

    @Override
    public void Toast(String s) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }


}
